package project.newCode.scenegraph;

import java.util.Stack;

import project.hulpPakket.Matrix4f;
import project.hulpPakket.Scene;
import project.newCode.surfaces.Box;
import project.newCode.transformations.Transformation;

public abstract class SceneTraverser {

	protected Stack<Transformation> matrixStack = new Stack<Transformation>();
	protected Stack<Transformation> inverseStack = new Stack<Transformation>();


	protected Scene scene;

	public SceneTraverser() {
		
	}
	public SceneTraverser(Scene s) {
		super();
		this.scene = s;
	}

	protected Matrix4f getRightProduct() {
		Matrix4f m = new Matrix4f();
		m.setIdentity();
		for(int i = 0; i<matrixStack.size(); i++) {
			m = Matrix4f.prod(m, matrixStack.get(i));
		}
		return m;
	}

	protected Matrix4f getLeftProduct() {
		Matrix4f m = new Matrix4f();
		m.setIdentity();
		for(int i = 0; i<inverseStack.size(); i++) {
			m = Matrix4f.prod(inverseStack.get(i),m);
		}
		return m;
	}
	public void visitEntry(CompositeTransform compositeTransform) {
		inverseStack.push(compositeTransform.getTransform().getInverse());
		matrixStack.push(compositeTransform.getTransform());
	}
	public abstract void visitEntry(LeafShape leafShape);

	public void visitLeave(CompositeTransform compositeTransform) {
		matrixStack.pop();
		inverseStack.pop();
	}

	public void visitLeave(LeafShape leafShape) {
		// TODO Auto-generated method stub
	
	}


}